def is_prime(z):
    if z <= 1:
        return False
    for i in range(2, int(z**0.5)+1):
        if z % i == 0:
            return False
    return True

def next_prime(z):
    while True:
        if is_prime(z):
            return z
        z += 1

def word_to_number(word):
    numbers = {'zero': '0', 'one': '1', 'two': '2', 'three': '3', 'four': '4', 'five': '5', 'six': '6', 'seven': '7', 'eight': '8', 'nine': '9'}
    return int(''.join(numbers[r] for r in word.split()))

input_words = input().split()

if len(input_words) != 3:
    print("Wrong input")
else:
    try:
        number = word_to_number(input_words[0]) * 100 + word_to_number(input_words[1]) * 10 + word_to_number(input_words[2])
        if 100 <= number <= 999:
            print(next_prime(number))
        else:
            print("Wrong input")
    except:
        print("Wrong input")
